﻿@{
    Layout = "~/Views/Shared/_AddEdit.cshtml";
}
@section header{
    <script type="text/javascript">
        function SaveBeforeCallBack() {
            if (document.getElementById("_mpassword").value != document.getElementById("mpassword1").value) {
                ListPrompt("密码确认不一致！");
                return true;
            }

            var KeyValues = "''";
            $(".GridViewSelectCheckBox:checked").each(function () {
                KeyValues += ",'" + $(this).val() + "'";
            });
            $("#_rolecodes").val(KeyValues);

            return false;
        }
        function SelectAllRows(id, checked) {
            var color = checked ? "#DFE8F6" : "transparent";
            $("#" + id + " .GridViewSelectCheckBox").prop("checked", checked);
            if (checked) {
                $("#" + id + " .GridViewRow").addClass("GridViewSelect");
            }
            else {
                $("#" + id + " .GridViewRow").removeClass("GridViewSelect");
            }
            layui.form.render();
        }



    </script>
}

<div class="poppan">
    <input type="hidden" name="_rolecodes" id="_rolecodes" />
    <input type="hidden" name="_bstopflag" id="_bstopflag" v-model="bstopflag" />
    <table>
        <tr>
            <td>用 户 名*</td>
            <td><input type="text" name="_susername" value='@ViewBag.data["susername"]' class="layui-input" /></td>
            <td colspan="2">
                <input id="_bstopflag_0" type="radio" name="_bstopflag" value="0" @(ViewBag.data["bstopflag"] == "0" ? "checked='checked'" : "") title="已激活" />
                <input id="_bstopflag_1" type="radio" name="_bstopflag" value="1" @(ViewBag.data["bstopflag"] == "1" ? "checked='checked'" : "") title="未激活" />
            </td>
        </tr>
        <tr>
            <td nowrap>用户名称*</td>
            <td><input type="text" name="_sshowname" value='@ViewBag.data["sshowname"]' class="layui-input" /></td>
            <td nowrap>联系电话/手机</td>
            <td><input type="text" name="_sphone" value='@ViewBag.data["sphone"]' class="layui-input" /></td>
        </tr>
        <tr>
            <td>用户密码</td>
            <td><input type="password" name="_mpassword" id="_mpassword" autocomplete="off" class="layui-input" /></td>
            <td>密码确认</td>
            <td><input type="password" id="mpassword1" autocomplete="off" class="layui-input" /></td>
        </tr>
        <tr>
            <td>联系人</td>
            <td><input type="text" name="_slinkman" value='@ViewBag.data["slinkman"]' class="layui-input" /></td>
            <td>联系地址</td>
            <td><input type="text" name="_saddress" value='@ViewBag.data["saddress"]' class="layui-input" /></td>
        </tr>
        <tr>
            <td>电子信箱</td>
            <td><input type="text" name="_semail" value='@ViewBag.data["semail"]' class="layui-input" /></td>
            <td>单位</td>
            <td><input type="text" name="_sunitname" value='@ViewBag.data["sunitname"]' class="layui-input" /></td>
        </tr>
        <tr>
            <td>用户类型*</td>
            <td>
                <input id="_userType_0" type="radio" name="_userType" value="0" @(ViewBag.data["UserType"].ToString() == "0" ? "checked='checked'" : "") title="正常" />
                <input id="_userTYpe_1" type="radio" name="_userType" value="1" @(ViewBag.data["UserType"].ToString() == "1" ? "checked='checked'" : "") title="顾问" />
            </td>
            <td>加盟商*</td>
            <td>
                <select name="_leagueId">
                    @foreach (var dr in ViewBag.League.Rows)
                    {
                        <option value="@dr["id"]" @(ViewBag.data["leagueId"].ToString() == dr["id"].ToString() ? "selected" : "")>@dr["name"]</option>
                    }
                </select>
            </td>
        </tr>
    </table>
</div>

<div class="poppanDiv">
    <table class="GridViewTable" id="editExp">
        <tr class="GridViewHeader">
            <td class="GridViewCheckBox"><input type="checkbox" lay-filter="checkAll" alt="选择所有行" lay-skin="primary" /></td>
            <td class="GridViewHeaderField"><font>角色ID</font></td>
            <td class="GridViewHeaderField"><font>角色名称</font></td>
        </tr>
        @foreach (var data in ViewBag.UserRole.Rows)
        {
            <tr class="GridViewRow GridViewRow_@(ViewBag.UserRole.Rows.IndexOf(data)%2)" id='GridViewRow_@data["srolecode"]'>
                <td><input class="GridViewSelectCheckBox" type="checkbox" onclick="SelectRow('@data["srolecode"]',this);" value='@data["srolecode"]' @(data["state"] == 1 ? "checked='checked'" : "") lay-skin="primary" /></td>
                <td>@data["srolecode"]</td>
                <td>@data["srolename"]</td>
            </tr>
        }
    </table>
</div>
@section fooler{
<script>
    layui.use(['element', 'table', 'layer', 'laypage', 'form', 'laydate'], function () {
        layui.form.on('checkbox(checkAll)', function (data) {
            SelectAllRows('editExp', data.elem.checked);
        });
    });
</script>
}